<template>
  <div style="height: 40px; margin-top: 10px">
    <el-row>
      <el-col :span="4">
        <div class="grid-content">病人ID：{{ PatientInfo.patient_id }}</div>
      </el-col>
      <el-col :span="4">
        <div class="grid-content">床号:{{ PatientInfo.bed_number}}</div>
      </el-col>
      <el-col :span="4">
        <div class="grid-content">姓名:{{ PatientInfo.name }}</div>
      </el-col>
      <el-col :span="4">
        <div class="grid-content">性别:{{ PatientInfo.gender }}</div>
      </el-col>
      <el-col :span="4">
        <div class="grid-content">年龄:{{ PatientInfo.age }}</div>
      </el-col>
      <el-col :span="6">
        <div class="grid-content">诊断:{{ PatientInfo.diagnosis }}</div>
      </el-col>
    </el-row>
  </div>
</template>

<script>
var BaaS = require("minapp-sdk");
let clientID = "9ed0a3da89683e42d793";
BaaS.init(clientID);

export default {
  name: "test",
  data() {
    return {
      patient_id: '10001',
      PatientInfo:{
        patient_id: '',
        age: -1,
        name: "",
        gender: "",
        diagnosis: "",
        bed_number: -1,
      }
      
    };
  },
  methods:{
    getPatientInfo(index){
      let that = this;
      let query = new BaaS.Query();
      let patients = new BaaS.TableObject("patient");
      query.compare('patient_id', '=',  this.patient_id)
      patients
        .setQuery(query)
        .select([
          "age",
          "name",
          "gender",
          "diagnosis",
          "bed_number"
        ])
        .limit(1000)
        .offset(index)
        .find()
        .then((res) => {  
          if (res.data.meta.next !== null) {
            that.getEva_overall(index + 1000);
          } else {
            console.log(res.data.objects); //是一个数组
            console.log(res.data.objects[0]); // 获取对象
            let data  = res.data.objects[0];
            that.PatientInfo.patient_id = this.patient_id;
            that.PatientInfo.name = data.name;
            that.PatientInfo.age = data.age;
            that.PatientInfo.diagnosis = data.diagnosis;
            that.PatientInfo.bed_number = data.bed_number;
             if(data.gender = -1){
              that.PatientInfo.gender = '女';
            }else if (data.gender = 0) {
              that.PatientInfo.gender = '男';
            }
          }
        });
    },
    Init(){
      this.getPatientInfo(0);
    }
  },
  created(){
    this.Init();
  }
};
</script>

<style>
</style>